package com.ruoyi.web.controller.bus;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bus.domain.WitSite;
import com.ruoyi.bus.service.IWitSiteService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 站点管理Controller
 * 
 * @author caiyanshan
 * @date 2021-04-14
 */
@RestController
@RequestMapping("/bus/site")
public class WitSiteController extends BaseController
{
    @Autowired
    private IWitSiteService witSiteService;

    /**
     * 查询站点管理列表
     */
    @PreAuthorize("@ss.hasPermi('bus:site:list')")
    @GetMapping("/list")
    public TableDataInfo list(WitSite witSite)
    {
        startPage();
        List<WitSite> list = witSiteService.selectWitSiteList(witSite);
        return getDataTable(list);
    }

    /**
     * 导出站点管理列表
     */
    @PreAuthorize("@ss.hasPermi('bus:site:export')")
    @Log(title = "站点管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WitSite witSite)
    {
        List<WitSite> list = witSiteService.selectWitSiteList(witSite);
        ExcelUtil<WitSite> util = new ExcelUtil<WitSite>(WitSite.class);
        return util.exportExcel(list, "site");
    }

    /**
     * 获取站点管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('bus:site:query')")
    @GetMapping(value = "/{siteId}")
    public AjaxResult getInfo(@PathVariable("siteId") Long siteId)
    {
        return AjaxResult.success(witSiteService.selectWitSiteById(siteId));
    }

    /**
     * 新增站点管理
     */
    @PreAuthorize("@ss.hasPermi('bus:site:add')")
    @Log(title = "站点管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WitSite witSite)
    {
        return toAjax(witSiteService.insertWitSite(witSite));
    }

    /**
     * 修改站点管理
     */
    @PreAuthorize("@ss.hasPermi('bus:site:edit')")
    @Log(title = "站点管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WitSite witSite)
    {
        return toAjax(witSiteService.updateWitSite(witSite));
    }

    /**
     * 删除站点管理
     */
    @PreAuthorize("@ss.hasPermi('bus:site:remove')")
    @Log(title = "站点管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{siteIds}")
    public AjaxResult remove(@PathVariable Long[] siteIds)
    {
        return toAjax(witSiteService.deleteWitSiteByIds(siteIds));
    }
}
